var levelOrder = function (root) {
    let result = [], index = 0; // 深度优先
    const level = (root, index) => {
        if (!root) return
        if (!result[index]) result[index] = []
        result[index].push(root.val) 
        root.children.forEach(child => level(child, index + 1))
    }
    level(root, index)
    return result
};